﻿
@{
    ViewBag.Title = "省市区管理";
    Layout = "~/Views/Shared/_Layout_Content.cshtml";
}

<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>省市区管理</h5>
            <div class="ibox-tools">
                <a class="collapse-link">
                    <i class="fa fa-chevron-up"></i>
                </a>
            </div>
        </div>
        <div class="ibox-content">
            <div class="form-group">
                <button id="btnAdd" type="button" class="btn btn-primary "><i class="fa fa-plus"></i>&nbsp;添加</button>
                <button id="btnEdit" type="button" class="btn btn-info "><i class="fa fa-pencil"></i> 编辑</button>
                <button id="btnDel" type="button" class="btn btn-danger ">
                    <i class="fa fa-remove"></i>&nbsp;&nbsp;<span class="bold">删除</span>
                </button>
                <button id="btnCancel" type="button" class="btn btn-warning "><i class="fa fa-undo"></i> 取消选中状态</button>
                <button type="button" class="btn btn-warning" id="btnReloadArea"><i class="fa fa-undo"></i> 重置省市区数据</button>
            </div>

            <div class="jqGrid_wrapper">
                <ul id="areaTree" class="ztree">
                    <li>数据加载中......</li>
                </ul>
                <input type="hidden" id="txtParentId"/>
            </div>
        </div>
    </div>
</div>
@section styles    {
    <link href="~/css/plugins/ztree/metroStyle.css" rel="stylesheet" />
}
@section scripts
{
<environment names="Development">
    <script src="~/js/base.js"></script>
</environment>
<environment names="Staging,Production">
    <script src="~/js/base.min.js" asp-append-version="true"></script>
</environment>
    <script src="~/js/plugins/ztree/jquery.ztree.all.js"></script>
    <script src="~/js/page/jucheap.ztree.js"></script>
    <script type="text/javascript">
        var config = {
            id: 'areaTree',
            loadUrl: '@Url.Action("GetTrees")',
            addUrl: '@Url.Action("Add")',
            editUrl: '@Url.Action("Edit")',
            deleteUrl: '@Url.Action("Delete")',
            height: '360px',
            title:'区域信息'
        };
        var tree = new JuCheapTree(config);
        tree.load();
        $("#btnCancel").click(function() {
            var zTree = $.fn.zTree.getZTreeObj(config.id);
            zTree.cancelSelectedNode();
            $("#txtParentId").val("");
        });
        $(function() {
            $("#btnReloadArea").click(function() {
                XPage.DoPost(this, "@Url.Action("ReInitAreas", "System")", null, function() {
                    tree.load();
                }, null);
            });
        });
    </script>
}
